﻿<UserControl x:Class="Client.View.ChildParentView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
             xmlns:converters="clr-namespace:Client.Converters"
             xmlns:vm="clr-namespace:Client.ViewModel"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary  Source="pack://application:,,,/Client;component/Resources/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <converters:HierarchicalViewItemConverter x:Key="hierarchyConverter"/>
            <converters:ImageConverter x:Key="imageConverter"/>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>
        <DockPanel>
            <TextBlock DockPanel.Dock="Bottom" TextWrapping="Wrap" >
            </TextBlock>
            <TreeView ItemsSource="{Binding FizickoLice}" Background="{StaticResource NewPageBackground}" VerticalContentAlignment="Stretch">
                <TreeView.ItemContainerStyle>
                    <Style TargetType="{x:Type TreeViewItem}">
                        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                        <Setter Property="FontWeight" Value="Normal" />
                        <Setter Property="Background" Value="Transparent"/>
                        <Style.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="FontWeight" Value="Bold" />
                                <Setter Property="BorderBrush" Value="#FF143c65" />
                            </Trigger>

                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="#F5BA56" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </TreeView.ItemContainerStyle>

                <TreeView.Resources>
                    <HierarchicalDataTemplate DataType="{x:Type vm:ChildsViewModel}" ItemsSource="{Binding Children}">
                        <StackPanel Orientation="Horizontal">
                            <Border Grid.Column="0" Margin="2,2,2,2" BorderBrush="{StaticResource BaseColor}" BorderThickness="3,3,3,3" CornerRadius="10,10,10,10" VerticalAlignment="Center">
                                <Image Width="64" Height="64" Margin="3,0" Source="{Binding Parent.Slika, Converter={StaticResource imageConverter}}"/>
                            </Border>
                            <Border Grid.Column="0" Margin="2,2,2,2" BorderBrush="{StaticResource BaseColor}" VerticalAlignment="Center">
                            <TextBlock>
                                <TextBlock Text="{Binding Converter={StaticResource hierarchyConverter}}" FontSize="18" HorizontalAlignment="Center" VerticalAlignment="Center" />
                            </TextBlock>
                            </Border>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                </TreeView.Resources>                    
            </TreeView>
        </DockPanel>
    </Grid>
</UserControl>
